import hashlib
from flask import request


def paginate(queryset):
    """
    A paging method for query sets of flask-sqlalchemy
    """
    page = int(request.args.get('page', 1))
    size = int(request.args.get('page_size', 10))
    
    _limit = size if size else 10
    _offset = (page - 1) * _limit
    return queryset.limit(_limit).offset(_offset)


def do_md5(val):
    """
    md5 encryption
    """
    m = hashlib.md5()
    m.update(val.encode('utf-8'))
    return m.hexdigest()


if __name__ == '__main__':
    print(do_md5("123456"))
